package samples.spring.step2.beans;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

import samples.spring.beans.User;

/**
 * @author Zi Lai Ye
 * @date 2017/4/11
 */
public class UserWithInit extends User implements InitializingBean {

    public UserWithInit(){
        super();
        LOGGER.info("===========UserWithInit 构造方法被调用.");
    }

    public static final Logger LOGGER = LoggerFactory.getLogger(UserWithInit.class);

    public void init() {
        setId(1);
//        setAge(18);
        setName("test");
        LOGGER.info("==============={} init method invoked.", this.getClass().getSimpleName());
    }

    public void destroy() {
        LOGGER.info("================{} destroy method invoked.", this.getClass().getSimpleName());
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        LOGGER.info("============{} afterPropertiesSet method invoked.", getClass().getSimpleName());
    }
}
